#!/usr/bin/env bash
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
# Function :CentOS7.X docker-ce安装
# Platform :RedHatEL7.x Based Platform
# Version  :1.2
# Date     :2021-07-06
# Author   :mugoLH
# Contact  :houxiaoshuai@baidu.com & hxsaj@126.com
# Company  :
# depend on:init_os.sh
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
. ./init_os.sh
docker-ce_install(){
	# 关闭防火墙
	firewalld_disable
	#  2，关闭selinux
	selinux_off
	#  3，更新yum系统
	yum update -y
	#  4，安装配置管理功能和驱动依赖
	yum_install yum-utils device-mapper-persistent-data lvm2
	#  5，部署docker-ce的yum源
	yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
	#  6，查看所有仓库中 Docker 版本并选择
	yum list docker-ce --showduplicates | sort -r | awk -F "[-|:|.]" '{if ($4>=19) print$1"-"$2"-"$4"."$5"."$6}'
	#  7，安装 Docker
	yum install docker-ce-18.03.1.ce
	#  8，阿里云 docker 镜像仓库加速
	tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://l3rxe7k8.mirror.aliyuncs.com"]
}
EOF
	#  9，启动 Docker 并设置自启动docker
	systemctl start docker && systemctl enable docker
	#  systemctl daemon-reload
	#  systemctl restart docker
}
